package weekMatch.one_350;

public class LeeCode_01 {
    public static void main(String[] args) {
        System.out.println(distanceTraveled(5, 10));
    }
    private static int distanceTraveled(int mainTank, int additionalTank) {
        int ans = 0;
        while (mainTank > 0){
            if (mainTank >= 5){
                mainTank -= 5;
                if (additionalTank > 0){
                    mainTank++;
                    additionalTank--;
                }
                ans += 50;
            }else {
                ans += mainTank * 10;
                mainTank = 0;
            }
        }
        return ans;
    }
}